<template>
  <ApplicationFormBase ref="formBaseRef" v-bind="props" form-type="leave" />
</template>

<script setup lang="ts">
import { ref } from 'vue'
import ApplicationFormBase from './ApplicationFormBase.vue'

const props = defineProps<{
  templateId?: number | null
  templateName?: string
  mode?: 'create' | 'edit' | 'view'
  leaveId?: number | null
}>()

const formBaseRef = ref<InstanceType<typeof ApplicationFormBase> | null>(null)

defineExpose({
  handleSaveDraft: async () => {
    if (formBaseRef.value?.handleSaveDraft) {
      return await formBaseRef.value.handleSaveDraft()
    }
  },
  handleSubmit: async () => {
    if (formBaseRef.value?.handleSubmit) {
      return await formBaseRef.value.handleSubmit()
    }
  },
})
</script>
